import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react-swc'
import path from 'path'
 const url = '127.0.0.1'
 const port = '8000'
const DEV_HOST = `${url}:${port}`
// https://vitejs.dev/config/
export default defineConfig({
  server: {
    host: "0.0.0.0", //解决 vite use--host to expose
    port: 8080, //配置端口
    open: true, //配置默认打开浏览器
    proxy:{
      '/api': {
        target: `http://${DEV_HOST}`,
        changeOrigin: true,
        rewrite:(path) => path.replace(/^\/api/,"")
      },
    }
  },
  plugins: [react()],
  resolve: {
    alias: {
      '@': path.resolve(__dirname, './src')
    }
  },
})
